package com.leokok.jts.learning.jts.core.algorithm;

import org.junit.Test;
import org.locationtech.jts.algorithm.MinimumBoundingCircle;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.io.ParseException;
import org.locationtech.jts.io.WKTReader;

/**
 * 计算包涵所有点的最小圆(MBC)
 */
public class MinimumBoundingCircleTest {

    @Test
    public void mbc() throws ParseException {
        WKTReader wktReader = new WKTReader();
        Geometry geometry = wktReader.read("POINT (115.92698000000001 31.988870000000006)");

        MinimumBoundingCircle minimumBoundingCircle = new MinimumBoundingCircle(geometry);
        System.out.println(minimumBoundingCircle.getDiameter().toText());
        System.out.println(minimumBoundingCircle.getCircle().toText());
        System.out.println(minimumBoundingCircle.getMaximumDiameter().toText());
    }
}
